<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变形平移</title>
    <style>
        body {
            background-color: rgb(228, 228, 228);
        }
        
        .box1 {
            width: 200px;
            height: 200px;
            background-color: pink;
            margin: 0 auto;
            margin-top: 100px;
            /* 
                变形指通过css改变元素的形状或位置
                变形不会影响到界面的布局
                transform 用来设置元素的变形效果
                <1>平移
                    translateX()
                    translateY()
                    translateZ()
                <2>

            */
            /* 可填像素或者百分比(相对于自己尺寸的百分比值) */
            transform: translateX(100%)
            /* transform: scale(0.7, 1.4) */
        }
        /* .box2 {
            width: 200px;
            height: 200px;
            background-color: orangered;
            margin: 0 auto;
        } */
        
        .box3 {
            /* 居中方案只适用于box的大小是确定的 */
            background-color: cyan;
            /* margin: auto; */
            position: absolute;
            /* left: 0;
            right: 0;
            top: 0;
            bottom: 0; */
            /* 居中方案2 */
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
        }
        
        .box4,
        .box5 {
            width: 200px;
            height: 300px;
            background-color: white;
            margin: 0 auto;
            float: left;
            margin: 0 10px;
            transition: all .3s;
        }
        
        .box4:hover,
        .box5:hover {
            transform: translateY(-4px);
            box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.2);
        }
    </style>
</head>

<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3">XXXX</div>
    <div class="box4"></div>
    <div class="box5"></div>
</body>

</html>